home *** CD-ROM | disk | FTP | other *** search
/ The Games Machine 76 / XENIATGM66.iso / Indiana Jones / Indiana Jones.exe / RESOURCE / PREVIEW.GOB / cog_nub_blockcorrect.cog < prev    next >
Text File  |  1999-11-15  |  1KB  |  56 lines

  1. # Pushblock correction algorithm
  2. #
  3. # Add floor surfaces to suit, they're used only for message delivery
  4. # Floor surfaces do not have to be 2x2; a single large floor will send an entered message after every push 
  5. #
  6. # Cogs that change block position without pushing must report the new position to this cog (variable: oldpos)
  7. #     to keep the corrections on track
  8. #
  9.  
  10. symbols
  11. message        startup
  12. message        entered
  13.  
  14. surface        floor0    mask=0x080
  15.  
  16. thing        pushblock            nolink
  17.  
  18. vector        oldpos        local
  19. vector        newpos        local
  20.  
  21. flex        xfix=0.0    local
  22. flex        yfix=0.0    local
  23. flex        zfix=0.0    local
  24. end
  25.  
  26. code
  27. startup:
  28.     //Print("----------");
  29.     oldpos = GetThingPos(pushblock);
  30.     
  31.     //Print("Original Position");
  32.     //PrintVector(oldpos); 
  33.     
  34.     return;
  35.  
  36. entered:
  37.     //Print("before correction:");
  38.     newpos = GetThingPos(pushblock);
  39.     //PrintVector(GetThingPos(pushblock));
  40.  
  41.     # determine where it was supposed to be, relative to old position
  42.     xfix = Round(VectorX(VectorSub(oldpos, newpos)) * 10)/10;
  43.     yfix = Round(VectorY(VectorSub(oldpos, newpos)) * 10)/10;
  44.     zfix = Round(VectorZ(VectorSub(oldpos, newpos)) * 10)/10;
  45.     
  46.     # adjust it to proper position
  47.     SetThingPos(pushblock, VectorSet((VectorX(oldpos) - xfix), (VectorY(oldpos) - yfix), (VectorZ(oldpos) - zfix)));  
  48.  
  49.     //Print("after correction:");
  50.     //PrintVector(GetThingPos(pushblock));
  51.     
  52.     oldpos = GetThingPos(pushblock);
  53.     
  54.     return;
  55. end
  56.